package com.dynamic.data.source.service.impl;

import com.dynamic.data.source.config.datasource.DataSourceAdmin;
import com.dynamic.data.source.domain.User;
import com.dynamic.data.source.mapper.UserMapper;
import com.dynamic.data.source.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * 开发公司：联信
 * 版权：联信
 * <p>
 * Annotation
 *
 * @author 刘志强
 * @created Create Time: 2021/1/26
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public String login(String userName, String password) {
        User user = userMapper.getUserByUserNameAndPassword(userName,password);
        if (user != null) {
            String token = UUID.randomUUID().toString();
            DataSourceAdmin.userMap.put(token,user);
            return token;
        } else {
            return "无此用户";
        }
    }
}
